home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / dev / obero / Interfaces3_4.lha / Interfaces / Config.mod < prev    next >
Text File  |  1994-03-05  |  12KB  |  319 lines

  1. (*
  2. (*
  3. **  Amiga Oberon Interface Module:
  4. **  $VER: Config.mod 40.15 (28.12.93) Oberon 3.0
  5. **
  6. **   © 1993 by Fridtjof Siebert
  7. **   updated for V40.15 by hartmut Goebel
  8. *)
  9. *)
  10.  
  11. MODULE Config;  (* $Implementation- *)
  12.  
  13. IMPORT e * := Exec;
  14.  
  15. TYPE
  16.  
  17. (*
  18. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  19. ** read by the system software at configuration time.  Configuration of each
  20. ** board starts when the ConfigIn* signal is passed from the previous board
  21. ** (or from the system for the first board).  Each board will present it's
  22. ** ExpansionRom structure at location 00E80000H to be read by the system.
  23. ** This file defines the appearance of the ExpansionRom area.
  24. **
  25. ** Expansion boards are actually organized such that only one nybble per
  26. ** 16 bit word contains valid information.  The low nybbles of each
  27. ** word are combined to fill the structure below. (This table is structured
  28. ** as LOGICAL information.  This means that it never corresponds exactly
  29. ** with a physical implementation.)
  30. **
  31. ** The ExpansionRom space is further split into two regions:  The first 16
  32. ** bytes are read-only.  Except for the er_type field, this area is inverted
  33. ** by the system software when read in.  The second 16 bytes contain the
  34. ** control portion, where all read/write registers are located.
  35. **
  36. ** The system builds one "ConfigDev" structure for each board found.  The
  37. ** list of boards can be examined using the expansion.library/FindConfigDev
  38. ** function.
  39. **
  40. ** A special "hacker" Manufacturer ID number is reserved for test use:
  41. ** 2011 (7DBH).  When inverted this will look like 0F824H.
  42. *)
  43.  
  44.   ExpansionRomPtr * = UNTRACED POINTER TO ExpansionRom;
  45.   ExpansionRom * = STRUCT      (* -First 16 bytes of the expansion ROM *)
  46.     type         * : SHORTINT; (* Board type, size and flags *)
  47.     product      * : SHORTINT; (* Product number, assigned by manufacturer *)
  48.     flags        * : SHORTSET; (* Flags *)
  49.     reserved03   * : SHORTINT; (* Must be zero (0FFH inverted) *)
  50.     manufacturer * : INTEGER;  (* Unique ID,ASSIGNED BY COMMODORE-AMIGA! *)
  51.     serialNumber * : LONGINT;  (* Available for use by manufacturer *)
  52.     initDiagVec  * : INTEGER;  (* Offset to optional "DiagArea" structure *)
  53.     reserved0c   * : SHORTINT;
  54.     reserved0d   * : SHORTINT;
  55.     reserved0e   * : SHORTINT;
  56.     reserved0f   * : SHORTINT;
  57.   END;
  58.  
  59.  
  60. (*
  61. ** Note that use of the ec_BaseAddress register is tricky.  The system
  62. ** will actually write twice.  First the low order nybble is written
  63. ** to the ec_BaseAddress register+2 (D15-D12).  Then the entire byte is
  64. ** written to ec_BaseAddress (D15-D8).  This allows writing of a byte-wide
  65. ** address to nybble size registers.
  66. *)
  67.  
  68.   ExpansionControlPtr * = UNTRACED POINTER TO ExpansionControl;
  69.   ExpansionControl * = STRUCT   (* -Second 16 bytes of the expansion ROM *)
  70.     interrupt  * : SHORTINT; (* Optional interrupt control register *)
  71.     z3HighBase * : SHORTINT; (* Zorro III   : Config address bits 24-31 *)
  72.     baseAddress* : SHORTINT; (* Zorro II/III: Config address bits 16-23 *)
  73.     shutup     * : SHORTINT; (* The system writes here to shut up a board *)
  74.     reserved14 * : SHORTINT;
  75.     reserved15 * : SHORTINT;
  76.     reserved16 * : SHORTINT;
  77.     reserved17 * : SHORTINT;
  78.     reserved18 * : SHORTINT;
  79.     reserved19 * : SHORTINT;
  80.     reserved1a * : SHORTINT;
  81.     reserved1b * : SHORTINT;
  82.     reserved1c * : SHORTINT;
  83.     reserved1d * : SHORTINT;
  84.     reserved1e * : SHORTINT;
  85.     reserved1f * : SHORTINT;
  86.   END;
  87.  
  88. (*
  89. ** many of the constants below consist of a triplet of equivalent
  90. ** definitions: xxMASK is a bit mask of those bits that matter.
  91. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  92. ** number of bits that make up the definition.  This method is
  93. ** used when the field is larger than one bit.
  94. **
  95. ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
  96. ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
  97. *)
  98.  
  99. CONST
  100.  
  101. (* manifest constants *)
  102.   slotSize    * = 10000H;
  103.   slotMask    * = 0FFFFH;
  104.   slotShift   * = 16;
  105.  
  106. (* these define the free regions of Zorro memory space.
  107. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  108. *)
  109.   eExpansionBase      * = 000E80000H;    (* Zorro II  config address *)
  110.   eZ3ExpansionBase    * = 0FF000000H;    (* Zorro III config address *)
  111.  
  112.   eExpansionSize      * = 000080000H;    (* Zorro II  I/O type cards *)
  113.   eExpansionSlots     * = 8;
  114.  
  115.   eMemoryBase         * = 000200000H;    (* Zorro II  8MB space *)
  116.   eMemorySize         * = 000800000H;
  117.   eMemorySlotrs       * = 128;
  118.  
  119.   eZ3ConfigArea       * = 040000000H;    (* Zorro III space *)
  120.   eZ3ConfigAreaEnd    * = 07FFFFFFFH;    (* Zorro III space *)
  121.   eZ3SizeGranularity  * = 000080000H;    (* 512K increments *)
  122.  
  123.  
  124.  
  125. (**** er_Type definitions (ttldcmmm) ***************************************)
  126.  
  127. (* er_Type board type bits -- the OS ignores "old style" boards *)
  128.   ertTypeMask         * = -64;   (* Bits 7-6 *)
  129.   ertTypeBit          * = 6;
  130.   ertTypeSize         * = 2;
  131.   ertNewBoard         * = -64;
  132.   ertZorroII          * = ertNewBoard;
  133.   ertZorroIII         * = -128;
  134.  
  135. (* other bits defined in er_Type *)
  136.   ertbMemList        * = 5;  (* Link RAM into free memory list *)
  137.   ertbDiagValid      * = 4;  (* ROM vector is valid *)
  138.   ertbChainedConfig  * = 3;  (* Next config is part of the same card *)
  139.  
  140.   ertfMemList        * = 20H;
  141.   ertfDiagValid      * = 10H;
  142.   ertfChainedConfig  * = 08H;
  143.  
  144. (* er_Type field memory size bits *)
  145.   ertMemMask         * = 07H;  (* Bits 2-0 *)
  146.   ertMemBit          * = 0;
  147.   ertMemSize         * = 3;
  148.  
  149.  
  150.  
  151. (**** er_Flags byte -- for those things that didn't fit into the type byte ****)
  152. (**** the hardware stores this byte in inverted form                       ****)
  153.   erffMemSpace       * = -128;   (* Wants to be in 8 meg space. *)
  154.   erfbMemSpace       * = 7;      (* (NOT IMPLEMENTED) *)
  155.  
  156.   erffNoShutUp       * = 64;     (* Board can't be shut up *)
  157.   erfbNOShutUP       * = 6;
  158.  
  159.   erffExtended       * = 32;     (* Zorro III: Use extended size table *)
  160.   erfbExtended       * = 5;      (*            for bits 0-2 of er_Type *)
  161.                                   (* Zorro II : Must be 0 *)
  162.  
  163.   erffZorroIII       * = 16;     (* Zorro III: must be 1 *)
  164.   erfbZorroIII       * = 4;      (* Zorro II : must be 0 *)
  165.  
  166.   ertZ3SSMask        * = 0FH;    (* Bits 3-0.  Zorro III Sub-Size.  How *)
  167.   ertZ3SSBit         * = 0;      (* much space the card actually uses   *)
  168.   ertZ3SSSize        * = 4;      (* (regardless of config granularity)  *)
  169.                                  (* Zorro II : must be 0        *)
  170.  
  171.  
  172. (* ec_Interrupt register (unused) ********************************************)
  173.   ecibINTENA         * = 1;
  174.   ecibRESET          * = 3;
  175.   ecibINT2PEND       * = 4;
  176.   ecibINT6PEND       * = 5;
  177.   ecibINT7PEND       * = 6;
  178.   ecibINTERRUPTING   * = 7;
  179.  
  180.   ecifINTENA         * = 2;
  181.   ecifRESET          * = 8;
  182.   ecifINT2PEND       * = 16;
  183.   ecifINT6PEND       * = 32;
  184.   ecifINT7PEND       * = 64;
  185.   ecifINTERRUPTING   * = -128;
  186.  
  187.  
  188.  
  189. (***************************************************************************
  190. **
  191. ** these are the specifications for the diagnostic area.  If the Diagnostic
  192. ** Address Valid bit is set in the Board Type byte (the first byte in
  193. ** expansion space) then the Diag Init vector contains a valid offset.
  194. **
  195. ** The Diag Init vector is actually a word offset from the base of the
  196. ** board.  The resulting address points to the base of the DiagArea
  197. ** structure.  The structure may be physically implemented either four,
  198. ** eight, or sixteen bits wide.  The code will be copied out into
  199. ** ram first before being called.
  200. **
  201. ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
  202. ** are offsets from the diag area AFTER it has been copied into ram, and
  203. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  204. ** the actual information, not how much address space is required to
  205. ** store it.)
  206. **
  207. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  208. ** is a logic one).
  209. **
  210. ** If your board is to make use of the boot facility then it must leave
  211. ** its config area available even after it has been configured.  Your
  212. ** boot vector will be called AFTER your board's final address has been
  213. ** set.
  214. **
  215. ****************************************************************************)
  216.  
  217. TYPE
  218.  
  219.   DiagAreaPtr * = UNTRACED POINTER TO DiagArea;
  220.   DiagArea * = STRUCT
  221.     config * : e.BYTE;       (* see below for definitions *)
  222.     flags * : SHORTSET;      (* see below for definitions *)
  223.     size * : INTEGER;        (* the size (in bytes) of the total diag area *)
  224.     diagPoint * : INTEGER;   (* where to start for diagnostics, or zero *)
  225.     bootPoint * : INTEGER;   (* where to start for booting *)
  226.     name * : INTEGER;        (* offset in diag area where a string *)
  227.                              (*   identifier can be found (or zero if no *)
  228.                              (*   identifier is present). *)
  229.  
  230.     reserved01 * : INTEGER;  (* two words of reserved data.  must be zero. *)
  231.     reserved02 * : INTEGER;
  232.   END;
  233.  
  234. CONST
  235.  
  236. (* da_Config definitions *)
  237. (*
  238. ** dacBYTEWIDE can be simulated using dacNIBBLEWIDE.
  239. *)
  240.   dacBusWidth    * = 0C0X;    (* two bits for bus width *)
  241.   dacNibbleWide  * = 000X;
  242.   dacByteWide    * = 040X;    (* BUG: Will not work under V34 Kickstart! *)
  243.   dacWordWide    * = 080X;
  244.  
  245.   dacBootTime    * = 030X;    (* two bits for when to boot *)
  246.   dacNever       * = 000X;    (* obvious *)
  247.   dacConfigTime  * = 010X;    (* call da_BootPoint when first configing *)
  248.                               (*   the device *)
  249.   dacBindTime    * = 020X;    (* run when binding drivers to boards *)
  250.  
  251. (*
  252. **
  253. ** These are the calling conventions for the diagnostic callback
  254. ** (from da_DiagPoint):
  255. **
  256. ** A7 -- points to at least 2K of stack
  257. ** A6 -- ExecBase
  258. ** A5 -- ExpansionBase
  259. ** A3 -- your board's ConfigDev structure
  260. ** A2 -- Base of diag/init area that was copied
  261. ** A0 -- Base of your board
  262. **
  263. ** Your board must return a value in D0.  If this value is NULL, then
  264. ** the diag/init area that was copied in will be returned to the free
  265. ** memory pool.
  266. *)
  267.  
  268.  
  269. TYPE
  270.  
  271. (*
  272. ** At early system startup time, one ConfigDev structure is created for
  273. ** each board found in the system.  Software may seach for ConfigDev
  274. ** structures by vendor & product ID number.  For debugging and diagnostic
  275. ** use, the entire list can be accessed.  See the expansion.library document
  276. ** for more information.
  277. *)
  278.  
  279.   ConfigDevPtr * = UNTRACED POINTER TO ConfigDev;
  280.   ConfigDev * = STRUCT (node * : e.Node)
  281.     flags     *: SHORTSET;     (* (read/write) *)
  282.     pad       *: SHORTINT;     (* reserved *)
  283.     rom       *: ExpansionRom; (* copy of board's expansion ROM *)
  284.     boardAddr *: e.APTR;       (* where in memory the board was placed *)
  285.     boardSize *: LONGINT;      (* size of board in bytes *)
  286.     slotAddr  -: INTEGER;      (* which slot number (PRIVATE) *)
  287.     slotSize  -: INTEGER;      (* number of slots (PRIVATE) *)
  288.     driver    *: e.APTR;       (* pointer to node of driver *)
  289.     nextCD    *: ConfigDevPtr; (* linked list of drivers to config *)
  290.     unused    *: ARRAY 4 OF LONGINT; (* for whatever the driver wants *)
  291.  END;
  292.  
  293. CONST
  294.  
  295. (* cd_Flags *)
  296.   cdshutUp     * = 0;   (* this board has been shut up *)
  297.   cdconfigMe   * = 1;   (* this board needs a driver to claim it *)
  298.   cdBadMemory  * = 2;   (* this board contains bad memory *)
  299.  
  300. TYPE
  301.  
  302. (*
  303. ** Boards are usually "bound" to software drivers.
  304. ** This structure is used by GetCurrentBinding() and SetCurrentBinding()
  305. *)
  306.  
  307.   CurrentBindingPtr * = UNTRACED POINTER TO CurrentBinding;
  308.   CurrentBinding * = STRUCT
  309.     configDev * : ConfigDevPtr;       (* first configdev in chain *)
  310.     fileName * : e.LSTRPTR;           (* file name of driver *)
  311.     productString * : e.LSTRPTR;      (* product # string *)
  312.     toolTypes * : e.APTR;             (* tooltypes from disk object *)
  313.   END;
  314.  
  315.  
  316. END Config.
  317.  
  318.  
  319.